home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 October: Mac OS SDK / Dev.CD Oct 97 SDK1.toast / Development Kits (Disc 1) / Apple Shared Library Manager / ASLM Examples / TestTools / Sources / TestFSet.cp < prev    next >
Encoding:
Text File  |  1996-11-19  |  2.3 KB  |  103 lines  |  [TEXT/MPS ]

  1. /*
  2.     File:        TestFSet.cp
  3.  
  4.     Contains:    Implementation of class TTestFSet
  5.  
  6.     Copyright:    © 1992-1994 by Apple Computer, Inc., all rights reserved.
  7.  
  8. */
  9.  
  10. #ifndef __TESTFSET__
  11. #include "TestFSet.h"
  12. #endif
  13. #ifndef __FSETTEST__
  14. #include "FSetTest.h"
  15. #endif
  16.  
  17. TTestFSet::TTestFSet()
  18. {}
  19.  
  20. TTestFSet::~TTestFSet()
  21. {}
  22.  
  23. void TTestFSet::InitTest(BooleanParm, BooleanParm, int, char**)
  24. {}
  25.  
  26. void TTestFSet::EndTest(BooleanParm, BooleanParm)
  27. {}
  28.  
  29. void TTestFSet::RunTestIteration(BooleanParm verbose, BooleanParm)
  30. {
  31.     OSErr    err;
  32.     TClassInfo* info;
  33.     info = GetLocalLibraryManager()->GetClassInfo(ClassID(kFSetParentID), &err);
  34.     if (info == NULL)
  35.     {
  36.         Printf("### ERROR: #%d getting the TClassInfo object\n", err);
  37.         return;
  38.     }
  39.     char*    id;
  40.     short    count    = 0;
  41.     short    mask    = 0;
  42.     while ((id = (char*)info->Next()) != NULL)
  43.     {
  44.         if (ClassID(id) == ClassID(kFSetTest1ID))
  45.         {
  46.             if (mask & 1)
  47.                 Printf("### ERROR: Get ID for function set #1 again\n");
  48.             else
  49.             {
  50.                 count += 1;
  51.                 mask |= 1;
  52.                 if (verbose)
  53.                     Printf("### INFO: Got ID for function set #1, version = %04X...%04X\n",
  54.                            info->GetMinVersion(), info->GetVersion());
  55.             }
  56.         }
  57.         else
  58.         if (ClassID(id) == ClassID(kFSetTest2ID))
  59.         {
  60.             if (mask & 2)
  61.                 Printf("### ERROR: Get ID for function set #2 again\n");
  62.             else
  63.             {
  64.                 count += 1;
  65.                 mask |= 2;
  66.                 if (verbose)
  67.                     Printf("### INFO: Got ID for function set #2, version = %04X...%04X\n",
  68.                            info->GetMinVersion(), info->GetVersion());
  69.             }
  70.         }
  71.         else
  72.         {
  73.             Printf("### ERROR: Get \"%s\" as one of the subclass IDs\n", id);
  74.         }
  75.     }
  76.     if (count != 2)
  77.         Printf("### ERROR: Got %u \"classes\" as subclasses of \"%s\"\n",
  78.                count, kFSetParentID);
  79.     else
  80.     {
  81.         TestFunction    test1;
  82.         TestFunction    test2;
  83.         test1 = (TestFunction)GetFunctionPointer(ClassID(kFSetTest1ID), kFunctionName, &err);
  84.         if (test1 == NULL)
  85.             Printf("### ERROR: #%d Getting function pointer for function set #1\n",
  86.                    err);
  87.         test2 = (TestFunction)GetFunctionPointer(ClassID(kFSetTest2ID), kFunctionName, &err);
  88.         if (test2 == NULL)
  89.             Printf("### ERROR: #%d Getting function pointer for function set #2\n",
  90.                    err);
  91.         if (test1 != NULL && test2 != NULL)
  92.         {
  93.             int a = (*test1)(5,2);
  94.             int b = (*test2)(5, 2);
  95.             if (a != 7)
  96.                 Printf("### ERROR: function set #1 returned %d instead of 7\n", a);
  97.             if (b != 3)
  98.                 Printf("### ERROR: function set #2 returned %d instead of 3\n", b);
  99.         }
  100.     }
  101.     delete info;
  102. }
  103.